window.onload=function(){
    let vm = new Vue({
        el:"#myaccount",
        data: {
            user: {
                userId:"",
                userName:""
            },
            orderList: {},
            addressList: {}
        },
        methods:{
            findUser(){
                console.log(JSON.parse(window.sessionStorage.getItem("user")).data);
                this.user=JSON.parse(window.sessionStorage.getItem("user")).data;

            },
            findAddress(){
                axios
                    .get("http://localhost:9090/findAddress",{
                        params:{
                            userId:this.user.userId
                        }
                    })
                    .then((result)=>{
                        this.addressList=result.data;
                        console.log(result.data);
                    })
            },
            findOrder(){
                axios
                    .get("http://localhost:9090/findOrderByUserId",{
                        params:{
                            userId:this.user.userId
                        }
                    })
                    .then((result)=>{
                        this.orderList=result.data;
                        console.log(this.orderList);
                    })
            },
            showOrder(order){
                console.log(document.getElementById("orderDetail").style.display);
                document.getElementById("orderDetail").style.display="block";
            }
        },
        filters:{
            filterPay(state){
                switch (state){
                    case 1:
                        return "未支付";
                    case 2:
                        return "已支付";
                    case 3:
                        return "线下付款";
                    case 4:
                        return "线下付款已收款";
                }
            },
            filterOrder(state){
                switch (state){
                    case 0:
                        return "未发货";
                    case 1:
                        return "已发货";
                    case 2:
                        return "已收货";
                    case 3:
                        return "退货中";
                    case 4:
                        return "已退货";
                }
            }
        },
        created(){
            this.findUser();
            this.findAddress();
            this.findOrder();
        }
    })
}